package main
import (
    "path/filepath"
    "os"
    "fmt"
    "flag"
    "strings"
)

type uploadFile struct {
    FilePath string
    FileName string
}

func getFilelist(path string) ([]uploadFile, error) {
	var (
		uploadFileList   = []uploadFile{}
		parentPath = path
        name string
	)
	err := filepath.Walk(path, func(path string, f os.FileInfo, err error) error {
		if f == nil {
			return err
		}
		if f.IsDir() {
			return nil
		}
		name = strings.Replace(path, parentPath, "", 1)
        uploadFile := uploadFile{
            FilePath:path,
            FileName:name,
        }
		uploadFileList = append(uploadFileList, uploadFile)
		return nil
	})
	if err != nil {
		fmt.Printf("filepath.Walk() returned %v\n", err)
		return nil, err
	}
	return uploadFileList, nil
}

func main(){
    flag.Parse()
    root := flag.Arg(0)
    fileList, err := getFilelist(root)
    println(fmt.Sprintf("err:[%+v] fileList:[%+v]", err, fileList))
}